package com.suse.ecommerce.serviceImp;

import com.suse.ecommerce.dao.AddressMapper;
import com.suse.ecommerce.pojo.Address;
import com.suse.ecommerce.pojo.AddressExample;
import com.suse.ecommerce.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    private AddressMapper addressMapper;
    @Override
    public List<Address> queryAllAdress(Integer userId) {
        AddressExample example=new AddressExample();
        AddressExample.Criteria criteria = example.createCriteria();
        criteria.andUserIdEqualTo(userId);
        List<Address> addresses = addressMapper.selectByExample(example);
        return addresses;
    }

    @Override
    public void addAddress(Address address) {
        addressMapper.insertSelective(address);
    }

    @Override
    public Address getAddressById(int id) {

        return addressMapper.selectByPrimaryKey(new Long(id));
    }


}
